package com.leetcode.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/12/29 19:49
 */
public class LC1995统计特殊四元组 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) nums[i] = Integer.parseInt(s[i]);
        writer.write(countQuadruplets(nums) + "\n");
        writer.flush();
    }

    public static int countQuadruplets(int[] nums) {
        int res = 0, n = nums.length;
        for (int a = 0; a < n - 3; ++a) {
            for (int b = a + 1; b < n - 2; ++b) {
                for (int c = b + 1; c < n - 1; ++c) {
                    for (int d = c + 1; d < n; ++d) {
                        if (nums[a] + nums[b] + nums[c] == nums[d]) ++res;
                    }
                }
            }
        }
        return res;
    }
}
